<%- include ('../public/page_header.ejs')%>
<script type="text/javascript" src="/static/admin/js/jqPaginator.js"></script>

<div class="container-fluid">
  <div class="row">

    <div class="panel panel-default">
      <div class="panel-heading clear">
          <a href="/<%=config.adminPath%>/nav/add" class="btn btn-primary fl">增加导航</a>
      </div>

      <div class="table-responsive">
        <table class="table table-bordered">
          <thead>
            <tr class="th">
                <th>分类名称</th>
                <th>关联商品</th>
                <th>跳转地址</th>
                <th>位置</th>
                <th class="text-center">排序</th>
                <th class="text-center">状态</th>

                <th class="text-center">操作</th>
            </tr>
          </thead>
          <tbody>
            <%for(var i=0;i<list.length;i++){%>
              <tr>
                <td><%=list[i].title%></td>
                <td><%=list[i].relation%></td>
                <td><%=list[i].link%></td>
                <td>
                  <%if(list[i].position==1){%>
                    顶部
                  <%}else if(list[i].position==2){%>
                    中间
                  <%}else{%>
                    底部
                  <%}%>
                </td>
                                        

                <td class="text-center"><span onclick="app.editNum(this,'nav','sort','<%=list[i]._id%>', '<%=config.adminPath%>')"><%=list[i].sort%></span>
                </td>
                <td class="text-center">

                  <%if(list[i].status==1){%>
                    <img src="/static/admin/images/yes.gif" onclick="app.changeStatus(this,'nav','status','<%=list[i]._id%>', '<%=config.adminPath%>')" />

                  <%}else{%>
                    <img src="/static/admin/images/no.gif" onclick="app.changeStatus(this,'nav','status','<%=list[i]._id%>', '<%=config.adminPath%>')" />
                  <%}%>

                </td>                                                                    
                <td class="text-center"><a href="/<%=config.adminPath%>/nav/edit?_id=<%=list[i]._id%>">修改</a>
                  　<a class="delete" href="/<%=config.adminPath%>/nav/delete?_id=<%=list[i]._id%>">删除</a>
                </td>
              </tr>

            <%}%>
                      
          </tbody>
        </table>                        
     
      </div>        
      <div class="pagination fr" id="pagination">

      </div>
  </div>
  </div>
</div>

</body>

<script>
  $(function(){
    var totalPages = parseInt('<%= totalPages %>');
    var page = parseInt('<%= page %>');

    $('#pagination').jqPaginator({
      totalPages: totalPages,
      visiblePages: 10,
      currentPage: page,
      onPageChange: function (num, type) {
        // console.log(num, type)
        // $('#text').html('当前第' + num + '页');
        if (type == 'change') {
          location.href = "/<%= config.adminPath%>/nav?page=" + num;
        }
  
      }
    })
  })

</script>
</html>